<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>

    <script>
        //编写函数，完成取余运算，使其结果和 % 的结果一致。

    function fun(x,y){
        // if((!isNaN(x)) && (!isNaN(y))){
        //     return false
        // }
    var num = Math.floor(x / y)
        return x-y&num
    }
    console.log(fun(18,5));
        //编写函数，实现给函数传 任意长度的数组，都能返回对数组的实现从大到小的排列，
        function sum(num){
            for(var i = 0; i <= num.length; i++){
                for(var j = 0; j <= num.length-1-i;j++){
                    if(num[j]<num[j+1]){
                        temp=num[j];
                        num[j]=num[j+1];
                        num[j+1]=temp;
                    }
                }
            }
            return num
        } 
        var newArr = sum([1,13,44,72,3,33]);
        console.log(newArr);
          var arr = [3,5,22,44,11,3];
          for(var i=0; i<arr.length;i++){
              for(var j = 0;j<arr.length-1-i;j++){
                  if(arr[j] > arr[j+1]){
                      temp = arr[j];
                      arr[j]=arr[j+1];
                      arr[j+1] = temp 
                  }
              }
            //   return arr
          }
          console.log(arr);
        console.log('=============================================');
        function sort(arr,order){
            var result = [];
            for(var i= 0; i< arr.length;i++){
                if(order){
                    var num = Math.max.apply(window.arr);
                }else{
                    var num = Math.min.apply(window,arr);
                }
                result.push(num);
                var index = arr.indexOf(num);
                arr.splice(index,1);
                i=0
            }
            console.log(result);
        }
        var sum = [22,33,44,55,223,23,42,23];
        sort(sum)
        console.log(sum);
    </script>
</body>

</html>